'''
Created on May 24, 2009

@author: user
'''
import unittest
from cliques.cliqueFinder import cliqueFinder
from graph import graph
class test_cliqueFinder(unittest.TestCase):


    def setUp(self):
        self.clique_finder= cliqueFinder()


    def tearDown(self):
        pass


    def test_clique_found(self):
        test_graph = graph()
        test_graph.add_nodes([1,2,3,4,5])
        test_graph.add_edge(1,2)
        test_graph.add_edge(1,3)
        test_graph.add_edge(1,4)
        test_graph.add_edge(1,5)
        test_graph.add_edge(2,5)
        test_graph.add_edge(3,4)
        test_graph.add_edge(3,5)
        test_graph.add_edge(4,5)
        self.clique_finder.setup(test_graph)
        assert True==self.clique_finder.has_clique(4, test_graph.nodes())
        found_clique = self.clique_finder.find_clique(4,test_graph.nodes())
        found_clique = set(found_clique)
        assert found_clique==set([1,3,4,5])                                                   
        
        assert False==self.clique_finder.has_clique(5, test_graph.nodes())
        

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()